using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VVESTAMM
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                default:
                case "YGR":
                case "TST":
                    dwReturn["VEMANDANT"] = "00";
                    dwReturn["VEVERTNR"] = "00000001";
                    dwReturn["VEVERTNA"] = "        ";
                    dwReturn["VELAND"] = "   ";
                    dwReturn["VEPLZ"] = "            ";
                    dwReturn["VEORT"] = "                                        ";
                    dwReturn["VEBZ"] = "  ";
                    dwReturn["VEBZBEZ"] = "             ";
                    dwReturn["VECOUNTY"] = "    ";
                    dwReturn["VECITY"] = "    ";
                    dwReturn["VEANREDE"] = "3";
                    dwReturn["VENAME1"] = "                                        ";
                    dwReturn["VENAME2"] = "                                        ";
                    dwReturn["VESTRASSE1"] = "                                        ";
                    dwReturn["VESTRASSE2"] = "                                        ";
                    dwReturn["VEPLZPOSTF"] = "            ";
                    dwReturn["VEPOSTFACH"] = "               ";
                    dwReturn["VETEL"] = "                    ";
                    dwReturn["VETELEX"] = "                    ";
                    dwReturn["VEHOMEPAGE"] = "                                        ";
                    dwReturn["VEFAX"] = "                    ";
                    dwReturn["VEBTX"] = "                    ";
                    dwReturn["VEMAILADR"] = "                                        ";
                    dwReturn["VEBIC"] = "           ";
                    dwReturn["VESTAKZ"] = "A";
                    dwReturn["VESTADAT"] = "0";
                    dwReturn["VEVERTART"] = "A";
                    dwReturn["VEKUNDNR"] = "        ";
                    dwReturn["VEIBAN"] = "                                  ";
                    dwReturn["VEWAEHRSL"] = "   ";
                    dwReturn["VEDEBNR"] = "0";
                    dwReturn["VEKREDNR"] = "0";
                    dwReturn["VELABRDAT"] = "0";
                    dwReturn["VEKORT"] = "SH        ";
                    dwReturn["VEGEBIET"] = "   ";
                    dwReturn["VEABRZR"] = " ";
                    dwReturn["VEABRNACH"] = "R";
                    dwReturn["VESTDBON"] = "        ";
                    dwReturn["VEBABRZR"] = " ";
                    dwReturn["VEBONLDAT"] = "0";
                    dwReturn["VEANZEIGE"] = "N";
                    dwReturn["VEPROVPFL"] = "J";
                    dwReturn["VEBONPFL"] = "N";
                    dwReturn["VEKOLL"] = "N";
                    dwReturn["VEPRGRP"] = "N";
                    dwReturn["VEPROVGRP"] = "N";
                    dwReturn["VESKTOP"] = "0";
                    dwReturn["VEABRVBP"] = "   ";
                    dwReturn["VEABRVBB"] = "   ";
                    dwReturn["VEVERGART"] = " ";
                    dwReturn["VESPRKZ"] = "V";
                    dwReturn["VEKUNDE"] = "N";
                    dwReturn["VEABRART"] = "   ";
                    dwReturn["VELSPERFAX"] = "N";
                    dwReturn["VEDRUCKER"] = "  ";
                    dwReturn["VEAFILLER"] = "                                             ";
                    dwReturn["VEAENZL"] = "0";
                    dwReturn["VEAENB"] = "        ";
                    dwReturn["VEAEND"] = "0";
                    dwReturn["VENEUB"] = "        ";
                    dwReturn["VENEUD"] = "0"; 
                    break;
            }
        }
        public void InsertVESTAMM(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            dwData["VENEUB"] = app.User;
            dwData["VENEUD"] = date;
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "YGR":
                    or1.CommandText = "INSERT INTO VESTAMM ( VEMANDANT,VEVERTNR,VEVERTNA,VELAND,VEPLZ,VEORT,VEBZ,VEBZBEZ,VECOUNTY,VECITY,VEANREDE,VENAME1,VENAME2,VESTRASSE1,VESTRASSE2,VEPLZPOSTF,VEPOSTFACH,VETEL,VETELEX,VEHOMEPAGE,VEFAX,VEBTX,VEMAILADR,VEBIC,VESTAKZ,VESTADAT,VEVERTART,VEKUNDNR,VEIBAN,VEWAEHRSL,VEDEBNR,VEKREDNR,VELABRDAT,VEKORT,VEGEBIET,VEABRZR,VEABRNACH,VESTDBON,VEBABRZR,VEBONLDAT,VEANZEIGE,VEPROVPFL,VEBONPFL,VEKOLL,VEPRGRP,VEPROVGRP,VESKTOP,VEABRVBP,VEABRVBB,VEVERGART,VESPRKZ,VEKUNDE,VEABRART,VELSPERFAX,VEDRUCKER,VEAFILLER,VEAENZL,VEAENB,VEAEND,VENEUB,VENEUD)"
                    + " VALUES (:VEMANDANT:,:VEVERTNR:,:VEVERTNA:,:VELAND:,:VEPLZ:,:VEORT:,:VEBZ:,:VEBZBEZ:,:VECOUNTY:,:VECITY:,:VEANREDE:,:VENAME1:,:VENAME2:,:VESTRASSE1:,:VESTRASSE2:,:VEPLZPOSTF:,:VEPOSTFACH:,:VETEL:,:VETELEX:,:VEHOMEPAGE:,:VEFAX:,:VEBTX:,:VEMAILADR:,:VEBIC:,:VESTAKZ:,:VESTADAT:,:VEVERTART:,:VEKUNDNR:,:VEIBAN:,:VEWAEHRSL:,:VEDEBNR:,:VEKREDNR:,:VELABRDAT:,:VEKORT:,:VEGEBIET:,:VEABRZR:,:VEABRNACH:,:VESTDBON:,:VEBABRZR:,:VEBONLDAT:,:VEANZEIGE:,:VEPROVPFL:,:VEBONPFL:,:VEKOLL:,:VEPRGRP:,:VEPROVGRP:,:VESKTOP:,:VEABRVBP:,:VEABRVBB:,:VEVERGART:,:VESPRKZ:,:VEKUNDE:,:VEABRART:,:VELSPERFAX:,:VEDRUCKER:,:VEAFILLER:,:VEAENZL:,:VEAENB:,:VEAEND:,:VENEUB:,:VENEUD:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                //VAFMANDANT VAFKOLL VAFART VAFFARBE VAFBEZ VAFFFARBE

            }

            Connect2Proxy(or1);
        }
        public DataSet QueryVESTAMM(DataRow dwData, int option = 1)
        {
           
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM VESTAMM WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM VESTAMM    WHERE VEMANDANT=:VEMANDANT: AND VEVERTNR=:VEVERTNR:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case 2:
                    or1.CommandText = "SELECT *FROM VESTAMM   WHERE VEMANDANT=:VEMANDANT:"
                        +dwData["VEVERTNR"].ToString()
                        + dwData["VEVERTNA"].ToString();
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case -1:
                    or1.CommandText = "SELECT VEVERTNR,VEVERTNR AS KEY,VEVERTNA, VEVERTNA AS DES FROM VESTAMM   WHERE VEMANDANT=:VEMANDANT:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                
                default:
                    break;
            }
            SResult = Connect2Proxy(or1); 
            SResult.Tables[0].TableName = TableName; 
            return SResult;
        }
        public void DeleteVESTAMM(DataRow dwData, int option = 1)
        {

            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM VESTAMM    WHERE VEMANDANT=:VEMANDANT: AND VEVERTNR=:VEVERTNR:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }

        public void UpdateVESTAMM(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {
            if (dwData != null)
            {
                dwData["VEAENB"] = app.User;
                dwData["VEAEND"] = date;
            }
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                default:
                case 1:
                    or1.CommandText = "UPDATE VESTAMM SET VEMANDANT=:VEMANDANT:,VEVERTNR=:VEVERTNR:,VEVERTNA=:VEVERTNA:,VELAND=:VELAND:,VEPLZ=:VEPLZ:,VEORT=:VEORT:,VEBZ=:VEBZ:,VEBZBEZ=:VEBZBEZ:,VECOUNTY=:VECOUNTY:,VECITY=:VECITY:,VEANREDE=:VEANREDE:,VENAME1=:VENAME1:,VENAME2=:VENAME2:,VESTRASSE1=:VESTRASSE1:,VESTRASSE2=:VESTRASSE2:,VEPLZPOSTF=:VEPLZPOSTF:,VEPOSTFACH=:VEPOSTFACH:,VETEL=:VETEL:,VETELEX=:VETELEX:,VEHOMEPAGE=:VEHOMEPAGE:,VEFAX=:VEFAX:,VEBTX=:VEBTX:,VEMAILADR=:VEMAILADR:,VEBIC=:VEBIC:,VESTAKZ=:VESTAKZ:,VESTADAT=:VESTADAT:,VEVERTART=:VEVERTART:,VEKUNDNR=:VEKUNDNR:,VEIBAN=:VEIBAN:,VEWAEHRSL=:VEWAEHRSL:,VEDEBNR=:VEDEBNR:,VEKREDNR=:VEKREDNR:,VELABRDAT=:VELABRDAT:,VEKORT=:VEKORT:,VEGEBIET=:VEGEBIET:,VEABRZR=:VEABRZR:,VEABRNACH=:VEABRNACH:,VESTDBON=:VESTDBON:,VEBABRZR=:VEBABRZR:,VEBONLDAT=:VEBONLDAT:,VEANZEIGE=:VEANZEIGE:,VEPROVPFL=:VEPROVPFL:,VEBONPFL=:VEBONPFL:,VEKOLL=:VEKOLL:,VEPRGRP=:VEPRGRP:,VEPROVGRP=:VEPROVGRP:,VESKTOP=:VESKTOP:,VEABRVBP=:VEABRVBP:,VEABRVBB=:VEABRVBB:,VEVERGART=:VEVERGART:,VESPRKZ=:VESPRKZ:,VEKUNDE=:VEKUNDE:,VEABRART=:VEABRART:,VELSPERFAX=:VELSPERFAX:,VEDRUCKER=:VEDRUCKER:,VEAFILLER=:VEAFILLER:,VEAENZL=:VEAENZL:,VEAENB=:VEAENB:,VEAEND=:VEAEND:,VENEUB=:VENEUB:,VENEUD=:VENEUD:"
                        + " WHERE VEMANDANT=:VEMANDANT: AND VEVERTNR=:VEVERTNR:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
    }
}
